<?php 
class searchJobsAction extends AdminMaster{
	public function execute($request){
		$action = $request->getParameter('action_name', '');
		$candidate_id = intval($request->getParameter('candidate_id', 0));
		
		$data = array();
		if($action == ADMIN_DEFINED::SEARCH_JOB){
			$data = Jobs::searchJob($candidate_id);
		}
		
		/*
		$candidate = CandidatesTable::getDataById($candidate_id);
		
		
		
		if($action == ADMIN_DEFINED::SEARCH_JOB && count($candidate)){
			
			$oDateNow = new DateTime();
			$oDateBirth = new DateTime($candidate['date_of_birth']);
			$yearOld = $oDateNow->diff($oDateBirth);
			
			$jMajors = CandidateToMajorsTable::getListByCandidateId($candidate_id);
			$jMajorIds = array('-1');
			foreach($jMajors as $m){
				$jMajorIds[] = $m['major_id'];
			}
			
			$jLocations = CandidateToLocationCitiesTable::getListByCandidateId($candidate_id);
			$jLocationIds = array('-1');
			foreach($jLocations as $m){
				$jLocationIds[] = $m['location_city_id'];
			}
			
			$jLevels = CandidateEducationsTable::getDataList(array('filter_candidate_id'=>$candidate_id));
			$jLevelIds = array('-1');
			foreach($jLevels as $m){
				$arr = ArrayHelper::getArrayIds(MasterEducationLevels::getIdsFollowLevel($m['education_level_id'], false));
				foreach ($arr as $e){
					if(!in_array($e, $jLevelIds)){
						$jLevelIds[] = $e;
					}
				}
			}
			
			$jLangs  = CandidateToForeignLanguagesTable::getListByCandidateId($candidate_id);
			$jobLangLevelIds = array('-1');
			
			foreach($jLangs as $m){
				$arr = ArrayHelper::getArrayIds(MasterForeignLanguageLevels::getIdsFollowLevel($m['foreign_language_level_id'], false));
				$arrTmp = array();
				foreach ($arr as $e){
					if(!in_array($e, $arrTmp)){
						$arrTmp[] = $e;
					}
				}
				foreach($arrTmp as $item){
					$level_id = ForeignLanguageToLevelsTable::getIdByLanguageIdLevelId($m['foreign_language_id'], $item['foreign_language_level_id']);
					if(!in_array($level_id, $jobLangLevelIds)){
						$jobLangLevelIds[] = $level_id;
					}
				}
			}
			$candidateToJobs = CandidateToJobsTable::getListByCandidateId($candidate_id);
			$jobIdNotIns = array('-1');
			foreach($candidateToJobs as $can){
				$jobIdNotIns[] = $can['job_id'];
			}
			
			
			$data['jobs'] = JobsTable::getDataListForCandidate(array(
					//'total_experience_year'	=> intval($candidate['total_experience_year']),
					'language_to_level_ids'	=> $jobLangLevelIds,
					'ids_notin'				=> $jobIdNotIns,
					'year_old'				=> $candidate['date_of_birth'],
					'location_city_ids'		=> $jLocationIds,
					'major_ids'				=> $jMajorIds,
					'education_level_ids'	=> $jLevelIds,
					'require_salary'		=> $candidate['salary_require'],
					'require_gender'		=> $candidate['gender']
			));
		}
		*/
		$this->setVar('data', $data);
	}
}